/*
 * lark firmware - used by the lark wireless device
 *
 * PHY and RF functions
 *
 * Copyright (c) 2000-2014 CJTian <cjtian@actions-semi.com>
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License along
 * with this program; if not, write to the Free Software Foundation, Inc.,
 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 */

#ifndef __LARKFW_DESC_H_
#define __LARKFW_DESC_H_

#define TXDESC_HW_RDONLY
#define TXDESC_HW_RW
#define TXDESC_SW_RDONLY
#define TXDESC_SW_RW

// sizeof (tx_desc) = 136, 34 words
struct tx_desc {
	u8		hw_runtime_flag;
	u8		data_rate;
	struct {
		u8	smps_mode:2;
		u8	op_flag:2;
		u8	ack_policy:4;
	};
	u8		status_qos;
	u8		ra_lut_idx;
	u8		tx_power_level;
	u8		tx_serivce;
	u32		phy_tx_mode;
	u16		tsf_stamp;
	u8		tx_sta_idx;
	struct {
		u8	key_type:4;
		u8	cipher_type:4;
	};
	u32		next_desc;
	u32		frag_status;	/* max 16 frag, 2bits a group */
	u32		reserved[20];
	u8		long_retries_num;
	u8		short_retries_num;
	u8		long_retry_count;
	u8		short_retry_count;
	u8		rts_success_num;
	u8		rts_fail_num;

	u16		frame_len;
	u32		iv[2];

	u32		buf_start_addr;
	u32		sub_msdu_info;
	u8		qnum;
	u8		sub_msdu_num;
	u8		mac_hdr_len;
	u8		mac_hdr_offset;
	u8		data_rate[7];
	u8		tssi;
} __packed;

// sizeof (rx_desc) = 36 bytes, 9 words
struct rx_desc {
	u16		rx_frame_len;
	u8		data_rate;
	struct {
		u8	cipher_type: 4;
		u8	status: 4;
	};
	u8		timestamp;
	u8		snr;
	u8		rssi;
	u8		silence_level;
	u32		phy_rx_mode;
	u16		rx_legacy_len;
	u16		rx_service_filed;
	u16		rx_sig_quality;
	u16		reserved;
	u8		msdu_num;
	struct {
		u8	res: 4;
		u8	flags: 4;
	};
	u16		rx_buf_num;
	u16		rx_int_seq;
	u32		next_buf;	// pointer to next buffer in defrag

	u32		rx_buf;
	struct rx_desc *next;
	struct rx_desc *prev;

} __packed;

struct q_struct {
	u32	*head;
	u32 *tail;
	u32	*hw_header;
	u16	count;
	u16	status;
};



#endif //__LARKFW_DESC_H_